<?php

require_once "Zend/Registry.php";

/**
 * @see ZendX_JQuery_View_Helper_UiWidget
 */
require_once "ZendX/JQuery/View/Helper/UiWidget.php";

/**
 * Zen Imageloader
 *
 * @uses 	   Zend_View_Helper_FormText
 * @package    ZendX_JQuery
 * @subpackage View
 * @copyright  Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
 * @license    http://framework.zend.com/license/new-bsd     New BSD License
 */
class Zen_View_Helper_Imageloader_Widget extends ZendX_JQuery_View_Helper_UiWidget
{
    /**
     * Create a jQuery UI Widget Date Picker
     *
     * @link   http://docs.jquery.com/UI/Datepicker
     * @param  string $id
     * @param  string $value
     * @param  array  $params jQuery Widget Parameters
     * @param  array  $attribs HTML Element Attributes
     * @return string
     */
    public function imageloader_Widget($id, $value = null, array $params = array(), array $attribs = array())
    {
        $attribs = $this->_prepareAttributes($id, $value, $attribs);

        $jquery = $this->view->jQuery();
        $jquery->enable(); // enable jQuery Core Library
		
        $jquery->addJavascriptFile('/cms/library/Zen/View/Helper/Imageloader/imgareaselect/js/jquery.imgareaselect.js');
		$jquery->addStylesheet('/cms/library/Zen/View/Helper/Imageloader/imgareaselect/css/imgareaselect-animated.css');
		
		$jquery->addJavascriptFile('/cms/library/Zen/View/Helper/Imageloader/js/jquery.form.js');
		
        $jquery->addJavascriptFile('/cms/library/Zen/View/Helper/Imageloader/js/ajaxupload.js');
        $jquery->addJavascriptFile('/cms/library/Zen/View/Helper/Imageloader/js/zenimages1.js');
        $jquery->addStylesheet('/cms/library/Zen/View/Helper/Imageloader/css/upload.css');
        
		
        // TODO: Allow translation of DatePicker Text Values to get this action from client to server
        $params = ZendX_JQuery::encodeJson($params);

        $js = sprintf('%s("#%s").zenimages(%s);',
                ZendX_JQuery_View_Helper_JQuery::getJQueryHandler(),
                $attribs['id'],
                $params
        );

        $this->jquery->addOnLoad($js);

        return $this->view->formText($id, $value, $attribs);
    }

   
}